package com.esincrunch.sms;

import android.database.Cursor;

public class SMSItem {
	public static final String ID = "_id";
	public static final String THREAD = "thread_id";
	public static final String ADDRESS = "address";
	public static final String PERSON = "person";
	public static final String DATE = "date";
	public static final String READ = "read";
	public static final String BODY = "body";
	public static final String SUBJECT = "subject";

	public String mAddress;
	public String mBody;
	public String mSubject;
	public long mID;
	public long mThreadID;
	public long mDate;
	public long mRead;
	public long mPerson;

	private static int mIdIdx;
	private static int mThreadIdx;
	private static int mAddrIdx;
	private static int mPersonIdx;
	private static int mDateIdx;
	private static int mReadIdx;
	private static int mBodyIdx;
	private static int mSubjectIdx;
	
	
	public SMSItem(Cursor cur) {
		mID = cur.getLong(mIdIdx);
		mThreadID = cur.getLong(mThreadIdx);
		mAddress = cur.getString(mAddrIdx);
		mPerson = cur.getLong(mPersonIdx);
		mDate = cur.getLong(mDateIdx);
		mRead = cur.getLong(mReadIdx);
		mBody = cur.getString(mBodyIdx);
		mSubject = cur.getString(mSubjectIdx);
	}
	
	public static void initIdx(Cursor cur) {
		mIdIdx = cur.getColumnIndex( ID );
		mThreadIdx = cur.getColumnIndex( THREAD );
		mAddrIdx = cur.getColumnIndex( ADDRESS );
		mPersonIdx = cur.getColumnIndex( PERSON );
		mDateIdx = cur.getColumnIndex( DATE );
		mReadIdx = cur.getColumnIndex( READ );
		mBodyIdx = cur.getColumnIndex( BODY );
		mSubjectIdx = cur.getColumnIndex( SUBJECT );
	}
	
	public String toString() {
		String ret = ID + ":" + String.valueOf(mID) + " " +
			THREAD + ":" + String.valueOf(mThreadID) + " " +   
			ADDRESS + ":" + mAddress + " " + 
			PERSON + ":" + String.valueOf(mPerson) + " " + 
			DATE + ":" + String.valueOf(mDate) + " " +
			READ + ":" + String.valueOf(mRead) + " " + 
			SUBJECT + ":" + mSubject + " " + 
			BODY + ":" + mBody; 
		return ret;
	}

}
